package com.zhongshengnetwork.rightbe.game.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dd.CircularProgressButton;
import com.zhongshengnetwork.rightbe.R;

/**
 * Created by luojingxing on 2018/4/1.
 */

public class PKPopWindow extends PopupWindow {
    private View mMenuView;
    private RelativeLayout leftView;
    private RelativeLayout rightView;

    public CircularProgressButton pk_pop_left_window_bg;
    public CircularProgressButton pk_pop_left_window_circle;
    public ImageView pk_pop_left_window_header;
    public TextView pk_pop_left_window_nickname;
    public TextView pk_pop_left_window_area;
    public TextView pk_pop_left_window_level;
    public TextView pk_pop_left_window_fee;

    public CircularProgressButton pk_pop_right_window_bg;
    public CircularProgressButton pk_pop_right_window_circle;
    public ImageView pk_pop_right_window_header;
    public TextView pk_pop_right_window_nickname;
    public TextView pk_pop_right_window_area;
    public TextView pk_pop_right_window_level;
    public TextView pk_pop_right_window_fee;

    public PKPopWindow(Activity context, int direction){
        super(context);
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mMenuView = inflater.inflate(R.layout.pk_pop_window, null);
        leftView = (RelativeLayout)mMenuView.findViewById(R.id.pk_pop_left_window);
        rightView = (RelativeLayout)mMenuView.findViewById(R.id.pk_pop_right_window);
        if (direction == 0){
            leftView.setVisibility(View.VISIBLE);
            rightView.setVisibility(View.GONE);
            pk_pop_left_window_bg = (CircularProgressButton)mMenuView.findViewById(R.id.pk_pop_left_window_bg);
            pk_pop_left_window_circle = (CircularProgressButton)mMenuView.findViewById(R.id.pk_pop_left_window_circle);
            pk_pop_left_window_header = (ImageView)mMenuView.findViewById(R.id.pk_pop_left_window_header);
            pk_pop_left_window_nickname = (TextView)mMenuView.findViewById(R.id.pk_pop_left_window_nickname);
            pk_pop_left_window_area = (TextView)mMenuView.findViewById(R.id.pk_pop_left_window_area);
            pk_pop_left_window_level = (TextView)mMenuView.findViewById(R.id.pk_pop_left_window_level);
            pk_pop_left_window_fee = (TextView)mMenuView.findViewById(R.id.pk_pop_left_window_fee);
        }else {
            leftView.setVisibility(View.GONE);
            rightView.setVisibility(View.VISIBLE);
            pk_pop_right_window_bg = (CircularProgressButton)mMenuView.findViewById(R.id.pk_pop_right_window_bg);
            pk_pop_right_window_circle = (CircularProgressButton)mMenuView.findViewById(R.id.pk_pop_right_window_circle);
            pk_pop_right_window_header = (ImageView)mMenuView.findViewById(R.id.pk_pop_right_window_header);
            pk_pop_right_window_nickname = (TextView)mMenuView.findViewById(R.id.pk_pop_right_window_nickname);
            pk_pop_right_window_area = (TextView)mMenuView.findViewById(R.id.pk_pop_right_window_area);
            pk_pop_right_window_level = (TextView)mMenuView.findViewById(R.id.pk_pop_right_window_level);
            pk_pop_right_window_fee = (TextView)mMenuView.findViewById(R.id.pk_pop_right_window_fee);
        }
        //设置SelectPicPopupWindow的View
        this.setContentView(mMenuView);
        //设置SelectPicPopupWindow弹出窗体的宽
        this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
        //设置SelectPicPopupWindow弹出窗体的高
        this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        //设置SelectPicPopupWindow弹出窗体可点击
        this.setFocusable(true);
        //设置SelectPicPopupWindow弹出窗体动画效果
        if (direction == 0) {
            this.setAnimationStyle(R.style.LeftPopupAnimation);
        }else {
            this.setAnimationStyle(R.style.RightPopupAnimation);
        }
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(0xe0f0f0f0);
        //设置SelectPicPopupWindow弹出窗体的背景
        this.setBackgroundDrawable(dw);

    }

}
